package com.datatypes;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

public class UserTracks implements Serializable {

	private List<Track> tracks = null;

	public UserTracks() {
		tracks = new ArrayList<Track>();
	}

	public UserTracks(List<Track> tracks) {
		this.tracks = tracks;
	}

	public UserTracks(User user) {
		super();
		user.setLast_updated((Calendar.getInstance()).getTime().getTime());
	}

	public void addTrack(Track track, User user) {
		tracks.add(track);
		// user.setLast_updated((Calendar.getInstance()).getTime().getTime());
	}

	public void deleteTrack(int track, User user) {
		tracks.remove(track);
		user.setLast_updated((Calendar.getInstance()).getTime().getTime());
	}

	public void setTrackName(int track, String name, User user) {
		tracks.get(track).setName(name);
		user.setLast_updated((Calendar.getInstance()).getTime().getTime());
	}

	public List<Track> getTracksList() {
		return tracks;
	}

	public Track getTrack(int num) {
		return tracks.get(num);
	}

	public Track getTrack(long id) {
		for (Track t : tracks) {
			if (t.getDate() == id)
				return t;
		}
		return null;
	}

}
